#include<iostream>
#include<cstring>
using namespace std;
const int N = 1e5 + 10;
int h[N];
int ans[N];
int cnt;
int y;
int main()
{
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		if (n < 0) {
			cout << "-";
			n *= -1;
		}
		if (n == 1) {
			cout << 1 << endl;
			continue;
		}
		memset(h, 0, sizeof(h));
		cnt = 0;
		y = 1;
		h[y] = 1;
		while (y) {
			y *= 10;
			ans[cnt++] = y / n;
			y %= n;
			if (h[y]) {
				break;
			}
			h[y] = 1;
		}
		cout << "0.";
		for (int i = 0; i < cnt; i++) {
			cout << ans[i];
		}
		cout << endl;
	}
	return 0;
}